<?php
namespace App\Http\Controllers\Home;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Session;
use DB;
		class HomeController extends Controller{
			public $value="";
			public function index(Request $request){
				if($request->session()->has('u_name')){
				    $this->value = $request->session()->get('u_name');
				}
				$c_one = DB::table('mo_cate')->where(array('parent_id'=>0))->get();
				foreach ($c_one as $k => $v) {
					$v->p_name = DB::table('mo_cate')->where(array('parent_id'=>$v->cate_id))->take(3)->get();
				}
				return view('home.index',array('c_one'=>$c_one))->with('session_value',$this->value);
			}
			public function logout_list(Request $request){
				if($request->session()->has('u_name')){
				   $request->session()->forget('u_name');
				}
				$c_one = DB::table('mo_cate')->where(array('parent_id'=>0))->get();
				foreach ($c_one as $k => $v) {
					$v->p_name = DB::table('mo_cate')->where(array('parent_id'=>$v->cate_id))->take(3)->get();
				}
				return view('home.index',array('c_one'=>$c_one))->with('session_value',$this->value);
			}
		}
?>
